#include <bits/stdc++.h>
#define MAXN 10000005
using namespace std;
int n,m1,m2,pl1[100005],pl2[100005],nxt1[MAXN],nxt2[MAXN],v1,v2,minv1,maxv1,minv2,maxv2;
bool Mp1[MAXN],Mp2[MAXN];
struct pa{
	int layer;int r;
};
bool operator <(const pa &a,const pa &b)
{
	return a.r>b.r;
}
priority_queue<pa> q1,r1;
priority_queue<int> q2,r2;
inline int read()
{
	int fr=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9')
	{
		fr=(fr<<3)+(fr<<1)+(ch^'0');
		ch=getchar();
	}
	return fr;	
} 
int main()
{
	freopen("airport.in","r",stdin);
	freopen("airport.out","w",stdout);
	scanf("%d%d%d",&n,&m1,&m2);
	for(int i=1;i<=m1;i++)
	{
		v1=read();v2=read();
		maxv1=max(maxv1,v2);
		minv1=min(minv1,v1);
		nxt1[v1]=v2;
		Mp1[v1]=1;	
	}
	for(int i=1;i<=m2;i++)
	{
		v1=read();v2=read();
		maxv2=max(maxv2,v2);
		minv2=min(minv2,v1);
		nxt2[v1]=v2;
		Mp2[v1]=1;
	}
	for(int i=1;i<=m1;i++) q2.push(-1*i);
	for(int i=1;i<=m2;i++) r2.push(-1*i);
	pa inf={100005,10000005};
	q1.push(inf);r1.push(inf);
	for(int i=1;i<=maxv1;i++)
	{
		pa tmp=q1.top();
		if(i==tmp.r)
		{
			q1.pop();
			q2.push(-1*tmp.layer);
		}
		if(Mp1[i])
		{			
			int lay=-1*q2.top();
			q2.pop();
			pa pushed={lay,nxt1[i]};
			q1.push(pushed);
			pl1[lay]++;
		}
	}
	for(int i=1;i<=maxv2;i++)
	{
		pa tmp=r1.top();
		if(i==tmp.r)
		{			
			r1.pop();
			r2.push(-1*tmp.layer);
		}
		if(Mp2[i])
		{			
			int lay=-1*r2.top();
			r2.pop();
			pa pushed={lay,nxt2[i]};
			r1.push(pushed);
			pl2[lay]++;
		}
	}
	int w1=1,w2=1,ans=0;
	for(;pl1[w1]>0;w1++) pl1[w1]+=pl1[w1-1];
	for(;pl2[w2]>0;w2++) pl2[w2]+=pl2[w2-1];
	w1--;w2--;
	for(int i=0;i<=min(n,w1);i++) ans=max(ans,pl1[i]+pl2[min(n-i,w2)]);
	printf("%d",ans);
}
